home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_c / mc51bugs / q32540 < prev    next >
Text File  |  1988-07-20  |  2KB  |  58 lines

  1. Q32540 Incorrect Code with /Oal /AL and Nested Loops
  2. C Compiler
  3. 5.10   | 5.10
  4. MS-DOS | OS/2
  5.  
  6. Summary:
  7.    The code generated for the following program is incorrect when
  8. compiled with /Oal /AL. When you are looking at the generated code,
  9. the SI register is used in the outer loops to keep track of argc.
  10. However, within the loop, the SI register is corrupted and the loop
  11. will not terminate.
  12.    Microsoft has confirmed this to be a problem in Version 5.10. We
  13. are researching this problem and will post new information as it
  14. becomes available.
  15.  
  16. More information:
  17.    The following code reproduces this problem:
  18.  
  19. #define MAX_PATH_CHARS  80
  20. #define FILE_NAME_SIZE  80
  21. #define incr(i)         ++(i)
  22. #define decr(i)         --(i)
  23. #define NUL             '\0'
  24.  
  25. char buffer[MAX_PATH_CHARS];
  26.  
  27. #define USAGE   "usage: %s [ -d dir ] [ file ]\n"
  28. int
  29. decode_args (argc, argv)
  30.     int     argc;
  31.     char*   *argv;
  32. {
  33.     int     j;
  34.     char*   ap;
  35.     char    dir[MAX_PATH_CHARS];
  36.  
  37. int last;
  38.  
  39.         while (argc) {
  40.             if (argv[0][0] == '-') {
  41.                 for (ap = *argv + 1; *ap != NUL; incr(ap)) {
  42.                         decr(argc), incr(argv);
  43.                         strcpy(dir, *argv);
  44.                 }
  45.             } else
  46.                 while (j <= FILE_NAME_SIZE && argv[0][j] != NUL) {
  47.                     buffer[last] = argv[0][j];
  48.                     incr(last), incr(j);
  49.                 }
  50.             decr(argc), incr(argv);
  51.         }
  52. }
  53.  
  54.  
  55.  
  56. Keywords:  buglist5.10
  57. Updated  88/07/21 03:19
  58.